package com.xxx.service;

import com.xxx.pojo.Account;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/7/15 9:35
 * @Copyright 博为峰
 */
public class Bank {

    public Account[] accounts = new Account[3];

    public Bank() {
        accounts[0] = new SavingAccount("110", "1234656", 1000);
        accounts[1] = new SavingAccount("119", "1234656", 1999);
        accounts[2] = new CreditAccount("120", "1234656", 1200);
    }

    public Account verify(String cardNo, String password) {
        for (int i = 0; i < accounts.length; i++) {
            if (accounts[i].getCardNo().equals(cardNo) && accounts[i].getPassword().equals(password)) {
                return accounts[1];
            }
        }
        return null;
    }

    public void saveMoney(Account account, int money) {
        account.save(money);
    }

    public void depositMoney(Account account, double money2) {
        account.deposit(money2);
    }
}
